//
//  UIBarButtonItem+Extension.swift
//  MicroBlog
//
//  Created by QT on 15/8/5.
//  Copyright © 2015年 綦敦涛. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    
    convenience init(imgName: String?,target: AnyObject?,action: String?) {
        let btn = UIButton()
        btn.setImage(UIImage(named: imgName!), forState: UIControlState.Normal)
        btn.setImage(UIImage(named: imgName! + "_highlighted"), forState: UIControlState.Highlighted)
        btn.sizeToFit()
        
        if let actionName = action{
            btn.addTarget(target, action: Selector(actionName), forControlEvents: UIControlEvents.TouchUpInside)
        }
        
        self.init(customView: btn)
    }
    

}
